import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';

class XinDongAppBarIconButton extends StatelessWidget {
  final bool isWhite;
  final IconData? icon;
  final AlignmentGeometry alignment;
  final Function()? onTap;

  const XinDongAppBarIconButton({Key? key, this.isWhite = false, this.icon, this.alignment = Alignment.center, this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return icon == null
        ? BackButton(
            color: isWhite ? Colors.white : DZColors.titleColor,
            onPressed: onTap ?? () => Navigator.maybePop(context),
          )
        : IconButton(
            icon: Icon(icon, color: isWhite ? Colors.white : DZColors.titleColor),
            iconSize: 30,
            alignment: alignment,
            onPressed: onTap ?? () => Navigator.maybePop(context),
          );
  }
}
